#******************************************************************************
#* common.mak
#* 
#* This file set the common bin tools.
#*
#* 
#******************************************************************************

CC := armcc
AS := armasm
LD := armlink
AR := armar

CCFLAGS = -c  -I./include ${JDS_INCLUDE_DIR} -O0 -ansi -g
ASFLAGS = -g
LDFLAGS = -scatter ${VM_CFG_DIR}/scatter -entry vmBootStartup 
ARFLAGS = -create 

RM    := rm -rf
MKDIR := mkdir
MV    := mv
CP    := cp -rf
ECHO  := echo

ECHO_NRL :=
ECHO_RED :=
ECHO_GRE :=
ECHO_YEL :=
ECHO_BLU :=
ECHO_CYA :=
ECHO_WHT :=

VM_OBJS = vmBoot.o vmLib.o vmLibA.o


BUILD_CC_OBJ    = ${AT}${CC} $< ${CCFLAGS} -o $@
BUILD_AS_OBJ    = ${AT}${AS} ${ASFLAGS} $< -o $@
BUILD_CC_DEPEND = ${AT}${CC} $< -M ${CCFLAGS} | sed "s,.*\.o[ :]*,$@ ${@:${DEPS_DIR}%.d=${OBJS_DIR}%.o} : ,g" > $@
BUILD_AS_DEPEND = ${AT}${AS} $< -M ${ASFLAGS} | sed "s,.*\.o[ :]*,$@ ${@:${DEPS_DIR}%.d=${OBJS_DIR}%.o} : ,g" > $@
BUILD_LIB       = ${AT}${AR} ${ARFLAGS} $@ ${OBJS}
MAKE_JDS_LIB    = ${AT}${MAKE} -C ${JDS_SRC_DIR}/${@:Lib.a=}
MAKE_USER_LIB   = ${AT}${MAKE} -C ./${@:Lib.a=}
define BUILD_TARGET
${AT}${LD} ${LDFLAGS} -symbols -info sizes,totals -map $(addprefix obj/, ${VM_OBJS}) $(addprefix lib/, ${USER_LIBS} ${JDS_LIBS}) -o $@.axf 2>$@.map
${AT}fromelf -bin -output $@.bin $@.axf
${AT}fromelf -i32 -output $@.hex $@.axf
endef

